//
//  LoginViewModel.swift
//  hunan_ios_ldnsm
//
//  Created by I-Q-I on 2019/4/28.
//  Copyright © 2019 I-Q-I. All rights reserved.
//

import Foundation
import HandyJSON


class RegisterModel  {
    func sendCode(by data: [String: Any], completion: @escaping (_ result: Bool, _ msg: String, _ data: Any ) -> Void) {
        let tel = "\(data["phone"] ?? "")"
        print(tel)
        if tel == "" && !(tel.isTelNumber()) {
            return completion(false, "请填写正确的手机号码", "")
        }
       
//        ApiProvider.request( UApi.sendCode(params: data), model: Empty.self) { (returnData) in
//           return completion(true, "发送成功", returnData)
//        }
    }
    func register(by data: [String: Any], completion: @escaping (_ result: Bool, _ msg: String, _ data: Any ) -> Void) {


 
        if data["username"] as! String == "" {
            print("手机号码不能为空!")
            return completion(false, "手机号码不能为空!", "")
            
        }
        if data["password"] as! String == "" {
            return completion(false, "密码不能为空!", "")
            
        }
        if  data["code"] as! String == ""  {
             return completion(false, "验证码不能为空!", "")
        }
        
//        ApiLoadingProvider.request(UApi.register(params: data), model: User.self) { (returnData) in
//            if let returnData = returnData {
//                return completion(true, "注册成功!", returnData)
//            } else {
//                return completion(false, "登录失败", "")
//                
//            }
//        }
        
    }
    
}


